import { unique, include, values, toArray, each } from './arr'
import { formatDate, searchObjDate } from './date'
import { trim, isFunction } from './func'
import { extend, extend2Lev, isEmptyObject } from './obj'
import { searchObjString, formatString } from './str'
import { utf8Encode, decodeURIComponent, encodeDates, base64Encode } from './code'
import {
  indexOf,
  slice,
  forEach,
  bind,
  _hasOwnProperty,
  _toString,
  isUndefined,
  isString,
  isDate,
  isBoolean,
  isNumber,
  isJSONString,
  isObject,
  isPlainObject,
  isArray,
  isFuction,
  isArguments,
  toString
} from './proto'

export * from './arr'
export * from './code'
export * from './date'
export * from './func'
export * from './obj'
export * from './proto'
export * from './str'

export function formatSystem(system) {
  var _system = system.toLowerCase()
  if (_system === 'ios') {
    return 'iOS'
  } else if (_system === 'android') {
    return 'Android'
  } else {
    return system
  }
}

export function getUUID() {
  return (
    '' +
    Date.now() +
    '-' +
    Math.floor(1e7 * Math.random()) +
    '-' +
    Math.random().toString(16).replace('.', '') +
    '-' +
    String(Math.random() * 31242)
      .replace('.', '')
      .slice(0, 8)
  )
}

const _ = {
  getUUID,
  formatSystem,
  indexOf,
  slice,
  forEach,
  bind,
  _hasOwnProperty,
  _toString,
  isUndefined,
  isString,
  isDate,
  isBoolean,
  isNumber,
  isJSONString,
  isObject,
  isPlainObject,
  isArray,
  isFuction,
  isArguments,
  toString,
  unique,
  include,
  values,
  toArray,
  each,
  formatDate,
  searchObjDate,
  utf8Encode,
  decodeURIComponent,
  encodeDates,
  base64Encode,
  trim,
  isFunction,
  extend,
  extend2Lev,
  isEmptyObject,
  searchObjString,
  formatString
}

export default _
